<template>
  <van-cell-group>
    <van-field v-model="item.value" :class="item.class" :placeholder="placeholder" :maxlength="item.colWidth" rows="2" autosize type="textarea" :disabled="item.disabled" :required="item.disabled ? false : item.required" show-word-limit :error-message="errMsg">
      <template #label>
        <span class="custom-title">{{ label }}
          <van-icon v-if="help" name="question" @click="showHelp" />
        </span>
      </template>
    </van-field>
  </van-cell-group>
</template>

<script>
import EleBase from './EleBase'
export default {
  name: 'EleTextArea',
  extends: EleBase,
  props: {
    item: {
      type: Object, // 类型
      default: null // 默认值
    }
  },
  computed: {
    errMsg() {
      let str = ''
      if (this.item.required && this.item.value === '') {
        if (this.item.undermsg === '') {
          str = '请选择' + this.item.label
        } else {
          str = this.item.undermsg
        }
      }
      return str
    },
    placeholder() {
      let str = ''
      if (this.item.placeholder) {
        str = this.item.placeholder
      } else if (this.item.label) {
        str = '请输入' + this.item.label
      }
      return str
    }
  },
  mounted() {

  }
}
</script>
